package cn.iocoder.yudao.module.erp.dal.mysql.invoicechecklist;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.erp.dal.dataobject.invoicechecklist.InvoiceCheckListDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.erp.controller.admin.invoicechecklist.vo.*;
import org.apache.ibatis.annotations.Update;

/**
 * ERP 采购发票审核单 Mapper
 *
 * @author 源码
 */
@Mapper
public interface InvoiceCheckListMapper extends BaseMapperX<InvoiceCheckListDO> {

    default PageResult<InvoiceCheckListDO> selectPage(InvoiceCheckListPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<InvoiceCheckListDO>()
                .eqIfPresent(InvoiceCheckListDO::getCheckInvoiceId, reqVO.getCheckInvoiceId())
                .eqIfPresent(InvoiceCheckListDO::getSupplierId, reqVO.getSupplierId())
                .eqIfPresent(InvoiceCheckListDO::getTotalPrice, reqVO.getTotalPrice())
                .eqIfPresent(InvoiceCheckListDO::getRemark, reqVO.getRemark())
                .eqIfPresent(InvoiceCheckListDO::getInvoiceStatus, reqVO.getInvoiceStatus())
                .eqIfPresent(InvoiceCheckListDO::getPayStatus, reqVO.getPayStatus())
                .eqIfPresent(InvoiceCheckListDO::getProcessInstanceId, reqVO.getProcessInstanceId())
                .betweenIfPresent(InvoiceCheckListDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(InvoiceCheckListDO::getId));
    }

    default InvoiceCheckListDO getInvoiceCheckListDOBycheckInvoiceId(String checkInvoiceId){
        return selectOne(InvoiceCheckListDO::getCheckInvoiceId,checkInvoiceId);
    }

    @Update("update erp_invoice_check_list set invoice_status = #{status} where check_invoice_id = #{checkInvoiceId}")
    void updateStatusByCheckInvoiceId(String checkInvoiceId, String status);

    @Update("update erp_invoice_check_list set pay_status = #{payStatus} where check_invoice_id = #{checkInvoiceId}")
    void updatePayStatusByCheckInvoiceId(String checkInvoiceId, String payStatus);
}